package navigation.wzg.com.navigation.Tools;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Handler;
import android.os.Message;

import org.json.JSONException;
import org.json.JSONObject;

import navigation.wzg.com.navigation.http.UpdateGET;

/**
 * Created by WZG on 2017/11/5.
 */

public class Toolstotal {
    /**
     * 分享
     * @param context
     */
    public static void share(Context context){
        Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_TEXT, "我在用日记本app，感觉还不错呢！下载地址:\n119.29.203.29/app-debug.apk");
        sendIntent.setType("text/plain");
        context.startActivity(Intent.createChooser(sendIntent,"分享：日记本"));
    }

    /**
     * 获取当前版本名
     * @param context
     * @return
     */
    public static String packageName(Context context) {
        PackageManager manager = context.getPackageManager();
        String name = null;
        try {
            PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
            name = info.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }

        return name;
    }

}
